package com.finalcial.service.impl;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.finalcial.dao.ApprovalDao;
import com.finalcial.service.ApprovalService;

@Service
public class ApprovalServiceImpl implements ApprovalService{
	
	@Autowired
	private ApprovalDao approvalDao;
	/**
	 * 修改工作状态（已办)、 新增工作审批状态（同意）、新增工作状态发送给经办人(未办)
	 */
	@Override
	public Integer approvalAgreeAndBckLog(String reimbursementId,
			String workStateName, Integer userId, String approvalOpinion,
			 String approvalStateName,String workStateNameUpdate,Integer userIdBySession) {
		Integer updateWork = approvalDao.updateWorkStateByWork(reimbursementId, workStateName, userIdBySession, workStateNameUpdate);
		Integer InsertApproval = approvalDao.insertExaminationMsg(reimbursementId, approvalOpinion, userIdBySession, approvalStateName);
		Integer inertWork = approvalDao.insertWorkStateByWork(reimbursementId, workStateName, userId);
		Integer total = updateWork+InsertApproval+inertWork;
		return total;
		
	}
	/**
	 * 修改工作状态(已办）、新增审批状态（未同意）
	 */
	@Override
	public Integer approvalDisAgreeAndBackLog(String reimbursementId,
			String workStateName,String approvalOpinion,
			 String approvalStateName,String workStateNameUpdate,Integer userIdBySession) {
		Integer updateWork = approvalDao.updateWorkStateByWork(reimbursementId, workStateName, userIdBySession, workStateNameUpdate);
		Integer InsertApproval = approvalDao.insertExaminationMsg(reimbursementId, approvalOpinion, userIdBySession, approvalStateName);
		Integer total = updateWork+InsertApproval;
		return total;
	}
	/**
	 * 修改工作状态（已阅）、新增工作状态给经办人（未办），修改审批状态（未同意变成同意）
	 */
	@Override
	public Integer approvalAgreeAndReading(String reimbursementId,
			String workStateName, Integer userId, String approvalOpinion,
			 String approvalStateName,String workStateNameUpdate,String approvalStateNameUpdate,Integer userIdBySession) {
		Integer updateWork = approvalDao.updateWorkStateByWork(reimbursementId, workStateName, userIdBySession, workStateNameUpdate);
		Integer insertWork = approvalDao.insertWorkStateByWork(reimbursementId, workStateName, userId);
		Integer updateApproval = approvalDao.updateExaminationMsg(reimbursementId, userIdBySession, approvalStateName, approvalOpinion, approvalStateNameUpdate);
		Integer total = updateWork+insertWork+updateApproval;
		return total;
	}
	/**
	 * 修改工作状态（已阅）
	 */
	@Override
	public Integer approvalDisAgreeAndReading(String reimbursementId,
			String workStateName, String approvalOpinion,
			String approvalStateName, String workStateNameUpdate,Integer userIdBySession) {
		Integer updateWork = approvalDao.updateWorkStateByWork(reimbursementId, workStateName, userIdBySession, workStateNameUpdate);
				return updateWork;
	}
	
	

	}
